#！/usr/bin/env python
#!coding=utf-8

from locale import currency
import os 
import sys
from tkinter.messagebox import NO
class Node:
    '''
        def node
        val:current node value
        next:next node point
    '''
    def __init__(self, val_, next_ = None):
        self.val = val_
        self.next = next_

# 定义链表的类
class LinkList(object):
    # 初始化头部节点并且初始化长度
    def __init__(self, head=None):
        self.head = head

    # 获取头部节点
    def get_head(self):
        return self.head

    # 判断链表是否为空链表
    def is_empty(self):
        if self.head == None:
            return True
        return False
    def init_list(self, data):
        if len(data) == 0:
            pass # no data
        else:
            data.reverse()
            p = None
            for each in data:
                current = Node(each)
                current.next = p
                p = current
            self.head = p
    def traverse(self):
        current = self.head
        data = []
        while current != None:
            value = current.val
            data.append(str(value))
            current = current.next
        sep = "->"
        print(sep.join(data))
    def append_node(self, value):
        if self.head == None:
            self.head = Node(value)
            self.head.next = None
        else:
            current = self.head
            while current.next != None:
                current = current.next
            current.next = Node(value)
            current = current.next
            current.next = None
    def reverse(self):
        current = self.head
        p = None
        tmp = None
        while current != None:
            tmp = current.next
            current.next = p
            p = current
            current = tmp
        self.head = p